<?php
require_once 'config.php';

class Controller {

    var $data;
    public function __construct() {
        // admin
        $this->data['url_current_ad'] = BASE_URL_ADMIN ."?mod=". $_GET['mod'] ."&act=". $_GET['act'];
    }

    public function view( $view_file, $dataForView = null ) {
        $smarty = new Smarty;

        $smarty->template_dir = __ROOT__.'/templates/default/';  // template folder
        $smarty->compile_dir = __ROOT__.'/templates/templates_c'; // template cache
        $smarty->cache_dir = __ROOT__.'/templates/cache'; // php cache
        $smarty->config_dir = __ROOT__.'/includes/smarty/config'; // smarty cache
        $smarty->left_delimiter = '<%';
        $smarty->right_delimiter = '%>';

        foreach ($dataForView as $key => $value) {
            $smarty->assign($key, $value);
            if ($key == 'notice') {
                if ($value == 'success') {
                    $smarty->assign('color', 'green');
                } else {
                    $smarty->assign('color', 'red');
                }
            }
        }
        $smarty->display( $view_file . '.html');
    }
}